package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.common.dto.BrandDTO;
import com.leyou.item.entity.Brand;
import com.leyou.item.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {

    @Select("\n" +
            "select * \n" +
            "from tb_brand\n" +
            "where id in(select tcb.brand_id\n" +
            "from tb_category_brand tcb \n" +
            "where tcb.category_id = #{id})")
    List<Brand> findBrandByCid(@Param("id") Long id);

    @Delete("delete from tb_category_brand where brand_id = #{id}")
    void deleteBrandById(@Param("id") Long id);
}
